/*
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd. 
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef INFER_LOG_H
#define INFER_LOG_H

#include "hilog/log.h"
#include <libgen.h>
#include <dirent.h>
#include <sys/stat.h>
#include <stdio.h>

namespace OHOS {
namespace AI_STD {

#ifdef __cplusplus
extern "C" {
#endif

#define LOG_INFO(fmt, args...) \
    printf("[INFO] %s:%d  %s - " fmt, basename(const_cast<char*>(__FILE__)), __LINE__, __FUNCTION__, ##args)

#define LOG_ERROR(fmt, args...) \
    printf("[ERROR] %s:%d  %s - " fmt, basename(const_cast<char*>(__FILE__)), __LINE__, __FUNCTION__, ##args)

#define LOG_WARNING(fmt, args...) \
    printf("[WARNING] %s:%d  %s - " fmt, basename(const_cast<char*>(__FILE__)), __LINE__, __FUNCTION__, ##args)

#if DEBUG
#define LOG_DEBUG(fmt, args...) \
    printf("[DEBUG] %s:%d  %s - " fmt, basename(const_cast<char*>(__FILE__)), __LINE__, __FUNCTION__, ##args)
#else
#define LOG_DEBUG(fmt, args...) 
#endif

static constexpr HiviewDFX::HiLogLabel g_ai_standard_LABEL = {
    LOG_CORE,
    0xE001B00,
    "AI_STD"
};

#define HILOGD(fmt, ...) (void)OHOS::HiviewDFX::HiLog::Debug(OHOS::AI_STD::g_ai_standard_LABEL, \
    "line: %d, function: %s," fmt, __LINE__, __FUNCTION__, ##__VA_ARGS__)

#define HILOGE(fmt, ...) (void)OHOS::HiviewDFX::HiLog::Error(OHOS::AI_STD::g_ai_standard_LABEL, \
    "line: %d, function: %s," fmt, __LINE__, __FUNCTION__, ##__VA_ARGS__)

#define HILOGF(fmt, ...) (void)OHOS::HiviewDFX::HiLog::Fatal(OHOS::AI_STD::g_ai_standard_LABEL, \
    "line: %d, function: %s," fmt, __LINE__FILE__, __FUNCTION__, ##__VA_ARGS__)

#define HILOGI(fmt, ...) (void)OHOS::HiviewDFX::HiLog::Info(OHOS::AI_STD::g_ai_standard_LABEL, \
    "line: %d, function: %s," fmt, __LINE__, __FUNCTION__, ##__VA_ARGS__)

#define HILOGW(fmt, ...) (void)OHOS::HiviewDFX::HiLog::Warn(OHOS::AI_STD::g_ai_standard_LABEL, \
    "line: %d, function: %s," fmt, __LINE__, __FUNCTION__, ##__VA_ARGS__)


#ifdef __cplusplus
}
#endif
}
}
#endif // INFER_LOG_H
